{% extends "base.html" %}


{% block title %}疫情防控系统-主页{% endblock %}


{% block content %}
    <div class="container-fluid">
          <div class="row">
              <div class="col-md-12">
                  <div id="interactive" style="height: 600px;"></div>
              </div>
              <!-- /.col -->
          </div>
          <!-- /.row -->
    </div><!--/. container-fluid -->
{% endblock %}


{% block script %}
    <!-- eChartsJS -->
    <script src="/static/js/echarts.js"></script>
    <script>
    // real_time = 1: todo 打开实时刷新数据
    var real_time = 1;
    var id_camera = -1;

    // todo 定时刷新堆叠曲线图
    var chartDom = document.getElementById('interactive');
    var myChart = echarts.init(chartDom, 'dark');
    var option;
    var updateInterval = 500;

    option = {
      title: {
        text: 'mask count'
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      },
      legend: {
        data: ['mask', 'no mask', 'all']
      },
      toolbox: {
        feature: {
          saveAsImage: {}
        }
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      },
      xAxis: [
        {
          type: 'category',
          boundaryGap: false,
          data: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40']
        }
      ],
      yAxis: [
        {
          type: 'value'
        }
      ],
      series: [
        {
          name: 'mask',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [120, 132, 101, 134, 90, 230, 210, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210, 90, 230, 210]
        },
        {
          name: 'no mask',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [220, 182, 191, 234, 290, 330, 310, 90, 230, 210, 220, 182, 191, 234, 290, 330, 310, 90, 230, 210, 220, 182, 191, 234, 290, 330, 310, 90, 230, 210, 220, 182, 191, 234, 290, 330, 310, 90, 230, 210]
        },
        {
          name: 'all',
          type: 'line',
          stack: 'Total',
          areaStyle: {},
          emphasis: {
            focus: 'series'
          },
          data: [150, 232, 201, 154, 190, 330, 410, 90, 230, 210, 150, 232, 201, 154, 190, 330, 410, 90, 230, 210, 150, 232, 201, 154, 190, 330, 410, 90, 230, 210, 150, 232, 201, 154, 190, 330, 410, 90, 230, 210]
        },
      ]
    };

    // 请求后端得到mask,no mask,all的数据
    function update() {
        $.get(
            // "/group_of_people/get_data?type=interactive&id_camera="+id_camera,
            "/api/capture/get_interactive_data",
            function (data, state) {
                // console.log(data);
                option.series = data.series;
                option && myChart.setOption(option);
                setTimeout(update, updateInterval)
            }
        );
    }
    option && myChart.setOption(option);
    if(real_time == 1){update();}

    </script>
{% endblock %}
